package ch.trainingtest.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import ch.trainingtest.base.entity.BaseEntity;
import ch.trainingtest.common.Constants;
import ch.trainingtest.common.NamedQueryConstants;

@Entity
@Table(name = "TUser")
@NamedQueries({
	@NamedQuery(name = NamedQueryConstants.USER_FIND_USER_BY_USERNAME_PASSWORD,
			query = "SELECT u FROM User u WHERE u.username = :pUsername AND u.password = :pPassword"),
			
	@NamedQuery(name = NamedQueryConstants.USER_SELECT_ALL_USER,
			query = "SELECT u FROM User u")
})



public class User extends BaseEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7326618095430730762L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	private int id;
	
	@Column(name = "username")
	private String username;
	
	@Column(name = "password")
	private String password;
	
	@OneToMany(mappedBy = "createdBy")
	private List<Task> tasks;

	public List<Task> getTasks() {
		return tasks;
	}

	public void setTasks(List<Task> tasks) {
		this.tasks = tasks;
	}

	public User() {
		super();
	}

	public User(String username, String password) {
		this.username = username;
		this.password = password;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	
	
}
